package com.hsgene.order.controller.peanut;

import com.hsgene.common.util.result.ApiResult;
import com.hsgene.order.domain.disease.GeneOrder;
import com.hsgene.order.exception.OrderErrorCode;
import com.hsgene.order.service.OrderService;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description:
 * @projectName: hdas-geneshop-server
 * @package: com.hsgene.order.controller.peanut
 * @author: maodi
 * @createDate: 2018/9/30 15:19
 * @version: 1.0
 * Copyright: Copyright (c) 2018
 */
@RestController
@RequestMapping(value = "/v1.0/genetic/testing")
public class PatientInfoConfirmController {

    private static Logger LOGGER = LogManager.getLogger(PatientInfoConfirmController.class);

    @Resource
    OrderService orderService;

    /**
     * @param orderId 订单id
     * @return int
     * @description 获取患者信息确认状态
     * @author maodi
     * @createDate 2018/10/31 9:18
     */
    @GetMapping("/orders/{order_id}/patient/confirm")
    public ApiResult<Integer> getPatientInfoConfirm(@PathVariable("order_id") String orderId) {
        try {
            if (StringUtils.isBlank(orderId)) {
                return ApiResult.fail(OrderErrorCode.ORDER_ID_IS_NOT_NULL);
            }
            Integer confirmFlag = orderService.getPatientInfoConfirm(orderId);
            if (confirmFlag == null) {
                return ApiResult.fail(OrderErrorCode.NOT_FOUND_PATIENT_INFO_CONFIRM_FLAG_BY_ORDER_ID);
            }
            return ApiResult.succ(confirmFlag);
        } catch (Exception e) {
            LOGGER.error(OrderErrorCode.PATIENT_INFO_CONFIRM_IS_ERROR.getMessage(), e);
            return ApiResult.fail(OrderErrorCode.PATIENT_INFO_CONFIRM_IS_ERROR);
        }
    }

}
